function Box(parent,options) {
    options = options || {};
    //设置对象的属性
    this.backgroundColor = options.backgroundColor || 'red';
    this.width = options.width ||20;
    this.height = options.height || 20;
    this.x = options.x || 0;
    this.y = options.y || 0;
    this.div = document.createElement('div');
    this.parent = parent;
    parent.appendChild(this.div);
    this.init()
}
//初始化div(方块)样式
Box.prototype.init = function () {
    let div = this.div;
    div.style.width = this.width+'px';
    div.style.height = this.height+'px';
    div.style.left = this.x +'px';
    div.style.top = this.y +'px';
    div.style.position = 'absolute';
    div.style.backgroundColor = this.backgroundColor;

};
Box.prototype.random = function () {
    let x = Tools.getRandom(0,this.parent.offsetWidth/this.width)*this.width;
    let y = Tools.getRandom(0,this.parent.offsetWidth/this.height)*this.height;
    this.div.style.left = x+'px';
    this.div.style.top = y+'px';

};
